<template>
  <div>
    <div class="info-wrapper">
      <p class="title">基本信息</p>
      <div class="info-list">
        <el-row :gutter="20">
          <el-col :span="6" v-for="(item, index) in info" :key="index">
            <div class="info">
              <p class="label">{{item.label}}：</p>
              <p class="content" v-if="item.key == 'contractNo'">158098</p>
              <p class="content" v-else>{{getVal(item.key)}}</p>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script>
import {infoList} from "./config"
export default {
  props: {
    type: {
      type: Number,
      default: 0
    },
    form: {
      type: Object,
      default:() => {}
    }
  },
  methods: {
    getVal(key){
        if(key == 'storageType') {
            return '散装'
        }
        if(key == 'currency') {
          return 'CNY(人民币)'
        }
        if (key == 'storageOut') {
          return ''
        }
        if('exCancelPerson,exCancelTime'.includes(key)) {
          return ''
        }
        if(key == 'time4' && this.form[key] && !isNaN(this.form[key])) {
          return this.common.dateFmt(this.form[key], "yyyy-MM-dd")+' 00:00:00'
        }
        if(key == 'expirationDate' && this.form[key] && !isNaN(this.form[key])) {
          return this.common.dateFmt(this.form[key], "yyyy-MM-dd")+' 23:59:59'
        }
        if(key == 'time2' && this.form[key] && !isNaN(this.form[key])) {
          return this.common.dateFmt(this.form[key], "yyyy-MM-dd")+' 23:59:59'
        }
        if('receivedTime,time1,createDate,createTime,exCancelTime,exDeferredTime,time5,exFactInStorageTime,checkDate,time7,exOnShelfTime,expectArrivedTime,predictLatestArrivedTime,predictArrivedTime,predictDeliverableTime,appointmentDate'.includes(key) && this.form[key] && !isNaN(this.form[key])) {
            return this.common.dateFmt(Number(this.form[key]), "yyyy-MM-dd hh:mm:ss")
        }
        if (this.form[key]) {
            return this.form[key]
        } else {
            return 'N/A'
        }
    }
  },
  computed: {
    info(){
        return infoList[this.type]
    }
  }
};
</script>

<style lang="scss" scoped>
.info-wrapper {
  padding: 10px;
  .title {
    font-size: 14px;
    font-weight: 600;
    height: 30px;
    line-height: 30px;
    border-bottom: 1px solid #ccc;
    margin-bottom: 8px;
  }
  .info-list {
    padding: 10px 20px;
    .info {
      font-size: 12px;
      margin-bottom: 20px;
      .label {
        margin-bottom: 10px;
      }
    }
  }
}
</style>
